package com.imti.mall.product.dao;

import com.imti.mall.model.pms.pojo.PmsProductCategory;
import com.imti.mall.product.mapper.PmsProductCategoryDynaSqlProvider;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * ClassName: PmsProductCategoryDao
 * Description:
 * date: 2022/9/12 21:41
 *
 * @author: youhun
 * @version:
 * @since JDK 1.8
 */

public interface PmsProductCategoryDao {
    /**
     * 添加商品分类表信息
     * @param pmsProductCategory
     * @return
     */
    @InsertProvider(type= PmsProductCategoryDynaSqlProvider.class,method="addPmsProductCategory")
    public Integer addPmsProductCategory(PmsProductCategory pmsProductCategory);

    /**
     * 修改商品分类表信息
     * @param pmsProductCategory
     * @return
     */
    @UpdateProvider(type= PmsProductCategoryDynaSqlProvider.class, method="updatePmsProductCategory")
    public Integer updatePmsProductCategory(PmsProductCategory pmsProductCategory);

    /**
     * 删除商品分类表信息
     * @param Id
     * @return
     */
    @Delete(" delete from pms_product_category where id=#{Id}")
    public Integer deletePmsProductCategory(Integer Id);

    /**
     * 动态SQL查询商品分类表 +分页
     * @param map
     * @return
     */
    @SelectProvider(type= PmsProductCategoryDynaSqlProvider.class,method="findPmsProductCategory")
    @Results({
            @Result(id=true,column="id",property="id"),
            @Result(column="parent_id",property="parentId"),
            @Result(column="name",property="name"),
            @Result(column="level",property="level"),
            @Result(column="product_count",property="productCount"),
            @Result(column="product_unit",property="productUnit"),
            @Result(column="nav_status",property="navStatus"),
            @Result(column="show_status",property="showStatus"),
            @Result(column="sort",property="sort"),
            @Result(column="icon",property="icon"),
            @Result(column="keywords",property="keywords"),
            @Result(column="description",property="description"),
    })
    public List<PmsProductCategory> findPmsProductCategory(Map<String,Object> map);


    /**
     * 动态SQL查询商品分类表详情
     * @param Id
     * @return
     */
    @Select("SELECT  id,parent_id,name,level,product_count,product_unit,nav_status,show_status,sort,icon,keywords,description FROM pms_product_category WHERE id=#{Id}")
    @Results({
            @Result(id=true,column="id",property="id"),
            @Result(column="parent_id",property="parentId"),
            @Result(column="name",property="name"),
            @Result(column="level",property="level"),
            @Result(column="product_count",property="productCount"),
            @Result(column="product_unit",property="productUnit"),
            @Result(column="nav_status",property="navStatus"),
            @Result(column="show_status",property="showStatus"),
            @Result(column="sort",property="sort"),
            @Result(column="icon",property="icon"),
            @Result(column="keywords",property="keywords"),
            @Result(column="description",property="description"),
    })
    public PmsProductCategory getPmsProductCategoryById(Integer Id);

    /**
     * 动态SQL查询商品分类表总条数
     * @param pmsProductCategory
     */
    @SelectProvider(type= PmsProductCategoryDynaSqlProvider.class,method="getPmsProductCategory")
    public Integer getPmsProductCategory(PmsProductCategory pmsProductCategory);

}
